package consultan.vanke.com.fragment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.viewpager.widget.ViewPager;

import com.amap.api.maps.AMap;
import com.amap.api.maps.MapView;
import com.androidkun.xtablayout.XTabLayout;

import java.util.ArrayList;

import butterknife.BindView;
import butterknife.OnClick;
import consultan.vanke.com.R;
import consultan.vanke.com.adapter.BaseFragmentAdapter;
import consultan.vanke.com.constant.ConstantLibrary;

public class ZsfzDetailFragment extends BaseFragment {
    @BindView(R.id.lienar_top)
    LinearLayout lienarTop;
    @BindView(R.id.linear_content)
    LinearLayout linearContent;
    @BindView(R.id.img_back)
    ImageView imgBack;
    @BindView(R.id.tablayout)
    XTabLayout tablayout;
    @BindView(R.id.vp_view)
    ViewPager vpView;
    @BindView(R.id.mapview)
    MapView mapview;
    @BindView(R.id.tv_text)
    TextView tvText;
    @BindView(R.id.linear_content_bt)
    LinearLayout linearContentBt;
    private View view;
    private ArrayList<String> titles;
    private ArrayList<BaseFragment> fragments;
    private AMap aMap;

    @Override
    protected void initViews() {
        titles = new ArrayList<>();
        titles.add("交通(2)");
        titles.add("教育(2)");
        titles.add("医疗(2)");
        titles.add("生活(2)");
        fragments = new ArrayList<>();
        fragments.add(new MapFragment());
        fragments.add(new MapFragment());
        fragments.add(new MapFragment());
        fragments.add(new MapFragment());
        BaseFragmentAdapter adapter = new BaseFragmentAdapter(getChildFragmentManager(), fragments, titles);
        vpView.setAdapter(adapter);
        vpView.setOffscreenPageLimit(ConstantLibrary.VIEWPAGERLIMIT);
        tablayout.setupWithViewPager(vpView);
    }

    @Override
    protected void initDatas() {
        mapview.onCreate(null);
        if (aMap == null) {
            aMap = mapview.getMap();
            aMap.getUiSettings().setZoomControlsEnabled(false);
        }
    }

    @Override
    protected void initEvents() {
        tablayout.addOnTabSelectedListener(new XTabLayout.OnTabSelectedListener() {
            @Override
            public void onTabSelected(XTabLayout.Tab tab) {
            }

            @Override
            public void onTabUnselected(XTabLayout.Tab tab) {
            }

            @Override
            public void onTabReselected(XTabLayout.Tab tab) {
            }
        });
        vpView.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
            @Override
            public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

            }

            @Override
            public void onPageSelected(int position) {

            }

            @Override
            public void onPageScrollStateChanged(int state) {

            }
        });
    }


    @Override
    protected View initContentView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        view = inflater.inflate(R.layout.fzzz_detail_fragment, null);
        return view;
    }

    @Override
    public void onSupportVisible() {
        super.onSupportVisible();
        setTranslucentStatusBar();
    }


    @Override
    public void onDestroy() {
        super.onDestroy();
    }

    @Override
    public void onResume() {
        super.onResume();
        setTranslucentStatusBar();
    }

    @OnClick(R.id.img_back)
    public void onViewClicked() {
        pop();
    }

}
